<template>
	<view>
		<view class="doctor">
			<view @click="toPage('patient')">病人</view>
			<view @click="toPage('personalInformation')">个人信息</view>
			<view @click="toEvaluate">宝贵建议</view>
			<view @click="exit">退出登录</view>
		</view>

		<uni-popup ref="alertDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="同意" title="通知" content="请先完善个人信息"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>

		<uni-popup ref="exitDialog" type="dialog">
			<uni-popup-dialog type="info" cancelText="关闭" confirmText="退出" title="提示" content="确认退出？"
				@confirm="exitDialogClose" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>
	</view>

</template>

<script>
	export default {
		data() {
			return {
				currentUser: this.$store.state.currentUser
			};
		},
		methods: {
			toPage(page) {
				if (page != 'personalInformation' && this.currentUser.name == undefined) {
					this.$refs.alertDialog.open()
					return
				}
				uni.navigateTo({
					url: `/pages/doctor/${page}/index`
				})
			},
			dialogConfirm() {
				// console.log('点击确认')
				uni.navigateTo({
					url: '/pages/doctor/personalInformation/index'
				})
			},
			dialogClose() {
				// console.log('点击关闭')
			},
			exit() {
				this.$refs.exitDialog.open()
			},
			exitDialogClose() {
				uni.reLaunch({
					url: "/pages/login/index"
				})
			},
			toEvaluate() {
				uni.navigateTo({
					url: "/pages/evaluate/index"
				})
			}
		},
		mounted() {
			if (this.currentUser.name == undefined) {
				this.$refs.alertDialog.open()
			}
		}
	}
</script>

<style lang="scss">
	.doctor {
		width: 100vw;
		display: flex;
		justify-content: space-evenly;
		padding: 50rpx 0;
		opacity: 0.8;
		background: linear-gradient(white, transparent);

		view {
			width: 150rpx;
			height: 100rpx;
			line-height: 100rpx;
			text-align: center;
			background-color: skyblue;
			border-radius: 20rpx;
		}
	}
</style>
